#include "ST_CG.h"
#include "Game/Game.h"
#include "Game/dConfig.h"
namespace LTGame
{
	#define kTagSpriteBatchNode 1

	ST_CG::ST_CG(GST_FLAG flag)
		:GameState(flag)
	{
		glClearColor(0x0, 0x0, 0x0, 0x0);
		img_cg = CCSprite::spriteWithFile("gui_pic/CG1.jpg");
		img_cg->setPosition(ccp(S_WIDTH_HALF, S_HEIGHT_HALF));	
		img_cg->retain();
		img_cg1 = CCSprite::spriteWithFile("gui_pic/CG2.jpg");
		img_cg1->setPosition(ccp(S_WIDTH_HALF, S_HEIGHT_HALF));	
		img_cg1->retain();
		commer_timer = 0;

	}
	ST_CG::~ST_CG()
	{
		CC_SAFE_DELETE(img_cg);
		CC_SAFE_DELETE(img_cg1);
		//CCGame->ClearCGString();
	}
	bool	ST_CG::logic(void)
	{
		return true;
	}
	void ST_CG::paint(void)
	{
		if (commer_timer<=3*FPS_RATE)
		{
			img_cg->visit();
			commer_timer++;
		}
		else if (commer_timer<=6*FPS_RATE)
		{
			img_cg1->visit();
			commer_timer++;
		}
		else 
		{
			img_cg1->visit();
			CCGame->SetState(GST_MainMenu);
		}
	}
	bool ST_CG::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
	{
		return true;
	}
	void ST_CG::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
	{
		CCPoint point = pTouch->locationInView( pTouch->view() );
		if (CCGame->m_uiData->isPointerInBlock(point.x, point.y, Form_SetMusic,B_Form_Block_4))
		{
			//CCGame->SetState(GST_Load);
		}
		
	}
	void ST_CG::playCG1Over()
	{
		CCGame->removeChildByTag(1000, true);
	}
	void ST_CG::playCG2Over()
	{
		CCGame->removeChildByTag(1001, true);
	}
}